package com.elanfox.littlereporter.dto;

import com.elanfox.littlereporter.common.CodeDescEnumHelper;
import com.elanfox.littlereporter.common.GradeType;
import com.elanfox.littlereporter.entity.ContributionPO;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * @author allan
 * @date 2018-03-25
 */
@Setter
@Getter
public class ContributionDTO {
    private String school;
    private int gradeType;
    private String className;
    private String reporterName;
    private String reporterNum;
    private String teacher;
    private String title;
    private String content;

    public ContributionPO toPO() {
        ContributionPO contributionPO = new ContributionPO();
        contributionPO.setSchool(school);
        contributionPO.setGradeType(CodeDescEnumHelper.getEnumTypeByCode(GradeType.class, gradeType));
        contributionPO.setClassName(className);
        contributionPO.setReporterName(reporterName);
        contributionPO.setReporterNum(reporterNum);
        contributionPO.setTeacher(teacher);
        contributionPO.setTitle(title);
        contributionPO.setContent(content);
        contributionPO.setCreateTime(new Date());

        return contributionPO;
    }
}
